<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./jq-3.6.0.js"></script>
</head>

<body>
    <div>书名:<input id="name" /></div>
    <div>作者:<input id="author" /></div>
    <div>价格:<input type="number" id="price" /></div>
    <div><button onclick="submit()">提交</button></div>
</body>
<script>
    const submit = () => {
        let name = $("#name").val()
        let author = $("#author").val()
        let price = $("#price").val()

        $.post('http://localhost:8082/books/add', {
            name: name,
            author: author,
            price: price,
        }, (res) => {
            if (res.affectedRows == 1) {
                alert('添加成功咯')
                window.location.href = 'index.html'
            } else {
                alert('添加失败咯')
            }
        })

    }
</script>

</html>